<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <base th:href="${#request.getContextPath()}+'/'">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">


</head>
<body>


<table class="table" formMode="view">
    <input name="customer_id" id="customer_id" type="hidden" value="">
    <tr>
        <th colspan="2" style="font-size:14px">增加商户</th>

    </tr>
    <tr>
        <td width="25%" align="right"><font color=red>*</font>商户名称：</td>
        <td >
            <input type="text" id ="customer_name" name="customer_name" 
                   class="input_style ipt" value=""/>
        </td>
    </tr>

    <tr>
        <td width="25%" align="right"><font color=red>*</font>QQ号码：</td>
        <td >
            <input type="text" id = "QQ" name="QQ" inputMode="numberOnly" 
                   class="input_style ipt" value=""/>
        </td>
    </tr>

    <tr>
        <td width="25%" align="right"><font color=red>*</font>微信号码：</td>
        <td >
            <input type="text" id = "wxh" name="wxh" 
                   class="input_style ipt" value=""/>
        </td>
    </tr>

    <tr>
        <td width="25%" align="right"><font color=red>*</font>联系电话：</td>
        <td >
            <input type="text" id = "phone" name="phone" 
                   class="input_style ipt" value=""/>
        </td>
    </tr>

    <tr>
        <td width="25%" align="right"><font color=red>*</font>登录账号：</td>
        <td >
            <input type="text" id = "login_name" name="login_name" 
                   class="input_style ipt" value=""/>
        </td>
    </tr>

    <tr>
        <td width="25%" align="right">登录密码：</td>
        <td >
            <input type="text" id = "login_pwd" name="login_pwd" 
                   class="input_style ipt" value=""/>

            (<font color=red>温馨提示：</font>如果不设置密码将使用默认密码：888888)

        </td>
    </tr>
    <tr>
        <td width="25%" align="right"><font color=red>*</font>商户等级：</td>
        <td >
            <select name="level" id="level" style="width:200px" class="selectBox">
                <option value="">请选择...</option>


                <option value="0" >非认证商户</option>

                <option value="1" >认证商户V1</option>
                <option value="2" >认证商户V2</option>
                <option value="3" >认证商户V3</option>



            </select>
        </td>
    </tr>
    <tr>
        <td width="25%" align="right"><font color=red>*</font>是否有效：</td>
        <td >
            <input type="radio" id = "enabled_ok" checked name="enabled" value="1"/>有效
            <input type="radio" id = "enabled_no"  name="enabled"  value="0"/>无效
            (<font color=red>温馨提示：</font>如果选择【无效】商户将无法登录且商户的商品不会出现在推广商品列表)
        </td>
    </tr>

    <tr height="45">
        <td height="45" align="right" colspan="2">
            <input type="button" onclick="addCust();" style="cursor: hand"
                   value="保存" />
            &nbsp;&nbsp;&nbsp;
            <input type="button" onclick="" style="cursor: hand"
                   value="返回" />
        </td>
    </tr>

</table>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="js/jquery-3.2.1.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script>
    function addCust() {
        var customerName = $("#customer_name").val();
        var qq = $("#QQ").val();
        var wxh = $("#wxh").val();
        var phone = $("#phone").val();
        var loginName = $("#login_name").val();
        var loginPwd = $("#login_pwd").val();
        var level = $("#level").val();
        var state = 1;
        var val = $("input[name='enabled']:checked").val();/*被选中的state值*/
        if (val==0){
            /*无效*/
           state = 0;
        }
        $.post("merchant/add",{customerName:customerName,qq:qq,wxh:wxh,phone:phone,loginName:loginName,loginPwd:loginPwd,
            level:level,state:state},
            function (data) {

                if (data.mark == 1){

                    alert("添加成功");

                } else {
                    alert("添加失败");

                }
            }

        );

    }

    function flush(){

                $("#right").load("merchant/merchant-list");

    }



</script>
</body>
</html>